package com.xiaoxi.exam.dao;

import com.xiaoxi.exam.model.Order;
import com.xiaoxi.exam.model.OrderExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface OrderMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    long countByExample(OrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    int deleteByExample(OrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    @Update({
        "update s_business.t_order",
        "set deleted_at = now()",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    @Select({
        "insert into s_business.t_order (order_no, subject, ",
        "detail, total_amount, ",
        "trade_no, channel, ",
        "discount_id, buyer_id, ",
        "open_id, status, ",
        "created_at, updated_at, ",
        "deleted_at, invalid_at, ",
        "pay_at, category, ",
        "category_status, ",
        "discount_money, exam_type)",
        "values (#{orderNo,jdbcType=VARCHAR}, #{subject,jdbcType=VARCHAR}, ",
        "#{detail,jdbcType=VARCHAR}, #{totalAmount,jdbcType=BIGINT}, ",
        "#{tradeNo,jdbcType=VARCHAR}, #{channel,jdbcType=SMALLINT}, ",
        "#{discountId,jdbcType=BIGINT}, #{buyerId,jdbcType=BIGINT}, ",
        "#{openId,jdbcType=VARCHAR}, #{status,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}, ",
        "#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, ",
        "#{deletedAt,jdbcType=TIMESTAMP}, #{invalidAt,jdbcType=TIMESTAMP}, ",
        "#{payAt,jdbcType=TIMESTAMP}, #{category,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}, ",
        "#{categoryStatus,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}, ",
        "#{discountMoney,jdbcType=SMALLINT}, #{examType,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler})", 
        " returning id"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    long insertReturningId(Order record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    @Insert({
        "insert into s_business.t_order (order_no, subject, ",
        "detail, total_amount, ",
        "trade_no, channel, ",
        "discount_id, buyer_id, ",
        "open_id, status, ",
        "created_at, updated_at, ",
        "deleted_at, invalid_at, ",
        "pay_at, category, ",
        "category_status, ",
        "discount_money, exam_type)",
        "values (#{orderNo,jdbcType=VARCHAR}, #{subject,jdbcType=VARCHAR}, ",
        "#{detail,jdbcType=VARCHAR}, #{totalAmount,jdbcType=BIGINT}, ",
        "#{tradeNo,jdbcType=VARCHAR}, #{channel,jdbcType=SMALLINT}, ",
        "#{discountId,jdbcType=BIGINT}, #{buyerId,jdbcType=BIGINT}, ",
        "#{openId,jdbcType=VARCHAR}, #{status,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}, ",
        "#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, ",
        "#{deletedAt,jdbcType=TIMESTAMP}, #{invalidAt,jdbcType=TIMESTAMP}, ",
        "#{payAt,jdbcType=TIMESTAMP}, #{category,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}, ",
        "#{categoryStatus,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}, ",
        "#{discountMoney,jdbcType=SMALLINT}, #{examType,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(Order record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    long insertSelectiveReturningId(Order record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    int insertSelective(Order record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    List<Order> selectByExample(OrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    @Select({
        "select",
        "id, order_no, subject, detail, total_amount, trade_no, channel, discount_id, ",
        "buyer_id, open_id, status, created_at, updated_at, deleted_at, invalid_at, pay_at, ",
        "category, category_status, discount_money, exam_type",
        "from s_business.t_order",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.xiaoxi.exam.dao.OrderMapper.BaseResultMap")
    Order selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    int updateByExampleSelective(@Param("record") Order record, @Param("example") OrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    int updateByExample(@Param("record") Order record, @Param("example") OrderExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    int updateByPrimaryKeySelective(Order record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_order
     *
     * @mbg.generated Wed Aug 08 14:00:38 CST 2018
     */
    @Update({
        "update s_business.t_order",
        "set order_no = #{orderNo,jdbcType=VARCHAR},",
          "subject = #{subject,jdbcType=VARCHAR},",
          "detail = #{detail,jdbcType=VARCHAR},",
          "total_amount = #{totalAmount,jdbcType=BIGINT},",
          "trade_no = #{tradeNo,jdbcType=VARCHAR},",
          "channel = #{channel,jdbcType=SMALLINT},",
          "discount_id = #{discountId,jdbcType=BIGINT},",
          "buyer_id = #{buyerId,jdbcType=BIGINT},",
          "open_id = #{openId,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler},",
          "created_at = #{createdAt,jdbcType=TIMESTAMP},",
          "updated_at = #{updatedAt,jdbcType=TIMESTAMP},",
          "deleted_at = #{deletedAt,jdbcType=TIMESTAMP},",
          "invalid_at = #{invalidAt,jdbcType=TIMESTAMP},",
          "pay_at = #{payAt,jdbcType=TIMESTAMP},",
          "category = #{category,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler},",
          "category_status = #{categoryStatus,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler},",
          "discount_money = #{discountMoney,jdbcType=SMALLINT},",
          "exam_type = #{examType,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Order record);
}